package com.yizhi.student.service.impl;

import org.apache.shiro.SecurityUtils;
import org.apache.shiro.subject.Subject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestParam;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Map;

import com.yizhi.common.redis.shiro.RedisCache;
import com.yizhi.common.redis.shiro.RedisManager;
import com.yizhi.common.redis.shiro.SerializeUtils;
import com.yizhi.common.utils.ShiroUtils;
import com.yizhi.student.dao.StudentInfoDao;
import com.yizhi.student.domain.StudentInfoDO;
import com.yizhi.student.service.StudentInfoService;
import com.yizhi.system.domain.UserDO;

import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisCluster;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.ShardedJedisPool;



@Service
public class StudentInfoServiceImpl implements StudentInfoService {

	
	@Autowired
	private StudentInfoDao studentInfoDao;
	
	@Override
	public StudentInfoDO get(Integer id){
		System.out.println("======service层中传递过来的id参数是：" + id + "======");
		return studentInfoDao.get(id);
	}


	@Override
	public List<StudentInfoDO> list(int currPage,int pageSize,Integer tocollegeId,Integer tomajorId,Integer classId,String name){
		return studentInfoDao.list(currPage,pageSize,tocollegeId,tomajorId,classId,name);
	}

	//"===================================================================================="


	@Override
	public int count(Map<String, Object> map){
		return studentInfoDao.count(map);
	}
	
	@Override
	public int save(StudentInfoDO studentInfo){
		studentInfo.setAddTime(new Date());
		studentInfo.setAddUserid(ShiroUtils.getUserId().intValue());
		return studentInfoDao.save(studentInfo);
	}
	
	@Override
	public int update(StudentInfoDO studentInfo){
//		System.out.println(ShiroUtils.getUserId());
		//把当前登录的用户信息放入变量
		studentInfo.setEditTime(new Date());
		studentInfo.setEditUserid(ShiroUtils.getUserId().intValue());
		return studentInfoDao.update(studentInfo);
	}
	
	@Override
	public int remove(Integer id){
		return studentInfoDao.remove(id);
	}
	
	@Override
	public int batchRemove(Integer[] ids){
		return studentInfoDao.batchRemove(ids);
	}
	
	public int getTotal(){
		return studentInfoDao.getTotal();
	}
	
}
